/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.system.source.model;

import com.system.source.data.DVDVCD;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Pinds
 */
public class DvdVcdTabelModel extends AbstractTableModel {

    private List<DVDVCD> isi = new ArrayList<DVDVCD>();

    public void tambahDVDVCD(DVDVCD dv) {
        isi.add(dv);
        fireTableRowsInserted(getRowCount(), getColumnCount());
    }

    public void hapusTabel(int i, int row) {
        isi.remove(i);
        fireTableRowsDeleted(i, row);
    }

    public DVDVCD getDvdVcd(int index) {
        return (DVDVCD) isi.get(index);
    }

    @Override
    public int getRowCount() {
        return isi.size();
    }

    @Override
    public int getColumnCount() {
        return 7;
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "Kode";
            case 1:
                return "Judul Film";
            case 2:
                return "Kode Jenis Film";
            case 3:
                return "Harga";
            case 4:
                return "Stock";
            case 5:
                return "Dipinjam";
            case 6:
                return "Cover";
            default:
                return null;
        }
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return isi.get(rowIndex).getKode_DVD();
            case 1:
                return isi.get(rowIndex).getJudulFilm();
            case 2:
                return isi.get(rowIndex).getKode_JenisFilm();
            case 3:
                return isi.get(rowIndex).getHarga();
            case 4:
                return isi.get(rowIndex).getStock();
            case 5:
                return isi.get(rowIndex).getDipinjam();
            case 6:
                return isi.get(rowIndex).getCover();
            default:
                return null;
        }
    }
}
